home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / stuffit.arc / GETDPF.ASM < prev    next >
Encoding:
Assembly Source File  |  1985-11-18  |  3.3 KB  |  109 lines

  1. ;GETDPF.ASM
  2. ;
  3. ;       Get drive\path\filename from command line
  4. ;
  5. ;6.13.85
  6. ;6.12.85
  7. ;4.30.85
  8. ;4.29.85
  9. ;hack of code from LIST547 by Vern Buerg
  10. ;
  11. comment ~
  12.  
  13. On entry:
  14.  
  15.         command line tail in DTA (80H)
  16.  
  17. On exit:
  18.  
  19.         dta2                    copy of original DTA for Get First/Get Next
  20.         dpathfilenm             d:\path\fname,0 ASCIIZ string, w/*.* if any
  21.         dpathfilenm_len         ASCIIZ string length, net of trailing zero
  22.  
  23.  
  24. Uses, requires:
  25.  
  26.     psp_dta
  27. ~
  28.  
  29. ;----------------------------------------------------------
  30. ;        constants, messages
  31. ;
  32.  
  33. help            db      'Syntax:  STUFIT filename.ext ',cr,lf
  34.                 db      cr,lf
  35.                 db      '         [\][path\]*.*  OK',cr,lf
  36.         db    cr,lf
  37.         db    'Path, but no drive: files must be on default drive. ',cr,lf,eos
  38.  
  39. ;----------------------------------------------------------
  40. ;        data storage
  41.  
  42. dta2            db      32 dup ('dta2')         ;copy of DTA (128 bytes)
  43. dpathfilenm     db      16 dup('filename')      ;length = 128 bytes
  44. dpathfilenm_len dw      0
  45. fileptr         dw      offset dpathfilenm      ;ptr to filename part of string
  46. blank           db      ' '
  47.  
  48. ;----------------------------------------------------------
  49. ;        main code
  50.  
  51. getdpath    proc    near
  52.  
  53. GETDPATHFNAME:
  54.         xor    ax,ax            ;zero AX
  55.         xor    cx,cx            ;zero CX
  56.             mov     al,byte ptr ds:[80H]
  57.         or    cx,ax            ;non-zero?
  58.             je      showhelp            ;show syntax and exit
  59.             mov     di,offset dta2          ;copy original line first
  60.         mov    cl,al            ;lngth of input line, net of cr
  61.         push    cx            ;save input length
  62.             mov     si,offset psp_dta+1
  63.             rep     movsb
  64.  
  65. ;now copy to work area:
  66.             mov     si,offset dta2
  67.             mov     di,offset dpathfilenm   ;full d:\p\*.* form
  68.         pop    cx            ;restore input line length
  69.  
  70.  
  71. blanks:        lodsb
  72.             cmp     al,blank        ;skip leading blanks
  73.         je    skipit
  74.         cmp    al,cr            ;ending cr?
  75.         je    gotparm
  76.         stosb
  77. skipit:        loop    blanks
  78.  
  79.  
  80. Gotparm:
  81. ;(How get to the following condition?  Already kicked out the zero-length cmd.)
  82. ;Still have to check for empty line (with blanks only)--VB checking to see if
  83. ;  his initial area load (zeroes) has been overlaid or not.
  84. ;       Cmp     Filenm,0                ;Any command line parameter?
  85. ;       Je      GetFile                 ; nope, ask for one
  86. ;Foregoing code depends on initial load, which is not reusable if we want to
  87. ;reinvoke this section for multiple files on the command line.
  88. ;Instead, test for length of command line as zero to kick out the help msg
  89. ;punch in a zero at the end of the string to make it ASCIIZ string
  90.             mov     byte ptr [di],0
  91. ;get string length if needed later for debug purposes:
  92.             mov     ax,di
  93.             sub     ax,offset dpathfilenm
  94.             mov     dpathfilenm_len,ax      ;length net of ASCIIZ "0" at end
  95. ;Check if zero--and send help if it is:
  96.             cmp     ax,0
  97.             je      showhelp
  98.             clc                             ;clear carry--OK return
  99.         ret
  100.  
  101. showhelp:
  102.             mov     dx,offset help
  103.         mov    ah,9h
  104.         int    21h
  105.             stc                             ;set carry for error return
  106.             ret
  107.  
  108. getdpath    endp
  109.